//
//  CTPopViewBase.m
//  CT
//
//  Created by liufanwei on 15/4/7.
//  Copyright (c) 2015年 liufanwei. All rights reserved.
//

#import "CTPopViewBase.h"

@interface CTPopViewBase(){
    BOOL _ShowKeyboard;
}

@end


@implementation CTPopViewBase
@synthesize IsAutoRemove=_IsAutoRemove;

-(void)awakeFromNib{
    _ShowKeyboard = YES;
    _ShowKeyboard = NO;
    self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.6];
    UITapGestureRecognizer * tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(onTap:)];
    [self addGestureRecognizer:tapGesture];
    
    [[NSNotificationCenter defaultCenter] addObserverForName:UIKeyboardDidShowNotification object:Nil queue:Nil usingBlock:^(NSNotification *note) {
        _ShowKeyboard = YES;
    }];
}

-(void)dealloc{
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

-(void)onTap:(UIGestureRecognizer*)gesture
{
    if (_ShowKeyboard) {
        [self hidKeyBoard];
        _ShowKeyboard = NO;
        return;
    }
    if (_IsAutoRemove) {
        [self removeFromSuperview];
    }
}

-(void)hidKeyBoard{
    
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
